题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1415
数据生成器:http://paste.ubuntu.com/22417252/
论文题,记忆化深搜
我在处理该去哪时,用的三方的floyd
然而hzwer告诉我,平方的bfs就好QAQ,反正没有T,我就不改啦!(づ ̄ 3 ̄)づ
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int MAXN = 1000+9; const int INF = 1000000; const double sta = -0.5; int n,m,C,M,d[MAXN][MAXN],to[MAXN][MAXN],cnt[MAXN]; double ans[MAXN][MAXN]; inline int read(){ char c=getchar(); int ret=0; while (c<'0'||c>'9') c=getchar(); while (c<='9'&&c>='0') ret=ret*10+c-'0',c=getchar(); return ret; } inline void Floyd(){ for (int k=1;k<=n;k++) for (int i=1;i<=n;i++) if (d[i][k] < INF) for (int j=1;j<=n;j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]); for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) for (int k=1;k<=n;k++) if (d[i][k] == 1 && d[k][j] == d[i][j]-1) {to[i][j] = k; break;} for (int i=1;i<=n;i++) to[i][i] = i; } double Get_Ans(int u, int v){ if (ans[u][v] > sta) return ans[u][v]; else { if (to[to[u][v]][v] != v) { ans[u][v] = Get_Ans(to[to[u][v]][v],v)+1; for (int i=1;i<=n;i++) if (d[v][i] == 1) ans[u][v] += Get_Ans(to[to[u][v]][v],i)+1; return ans[u][v] /= cnt[v]; } else return ans[u][v] = 1; } } int main(){ n = read(); m = read(); C = read(); M = read(); for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) d[i][j] = INF, ans[i][j] = -1; for (int i=1;i<=n;i++) d[i][i] = 0, ans[i][i] = 0, cnt[i] = 1; for (int i=1,a,b;i<=m;i++) cnt[a = read()]++, cnt[b = read()]++, d[a][b] = d[b][a] = 1; Floyd(); printf("%.3lf\n",Get_Ans(C,M)); return 0; }
I really liked your blog article. Really Great.
Appreciate you sharing, great article.
Enjoyed every bit of your post.Thanks Again. Awesome.
Very neat post.Really thank you! Want more.
Enjoyed every bit of your article.Really thank you! Really Cool.
Thanks so much for the blog post.Much thanks again. Cool.
Muchos Gracias for your blog.Thanks Again. Really Cool.
Im grateful for the article post. Will read on…
wow, awesome blog.Really looking forward to read more. Really Great.
Very good blog article.Thanks Again. Great.
Thank you for your blog.Really looking forward to read more. Really Cool.
Hey, thanks for the post.Really thank you! Great.
Great article post.Thanks Again. Cool.
Thanks for the post.Thanks Again. Really Great.
I appreciate you sharing this blog post.Thanks Again. Want more.
A big thank you for your article post.Really thank you! Really Cool.
wow, awesome post.Thanks Again. Awesome.
Really informative post.Thanks Again. Fantastic.
Thank you ever so for you post.Really looking forward to read more. Awesome.
I value the post.Much thanks again. Want more.
Enjoyed every bit of your blog.Thanks Again. Really Great.
Im grateful for the blog article.Thanks Again. Keep writing.
Enjoyed every bit of your blog article.Really thank you! Keep writing.
Im obliged for the article post. Fantastic.
Very informative blog post.Much thanks again. Much obliged.
Having read this I thought it was extremely informative.
I appreciate you taking the time and energy to put this information together.
I once again find myself personally spending way too much time both reading and
posting comments. But so what, it was still worth it!
You could definitely see your enthusiasm in the
work you write. The world hopes for more passionate writers like you who are not afraid to mention how they believe.
All the time go after your heart.
Keep on writing, great job!
Very informative blog post.Thanks Again. Great.
Im thankful for the post.Really thank you! Want more.
Thanks for the blog post.Really looking forward to read more. Really Great.
Appreciate you sharing, great article post. Will read on…
Hey, thanks for the post.Thanks Again. Keep writing.
Im obliged for the article.Much thanks again. Cool.
I loved your blog.Really thank you! Really Great.
Good post! We are linking to this particularly great content on our website.
Keep up the good writing.
Thanks for sharing, this is a fantastic blog post. Cool.
I am so grateful for your article.Really thank you!
There’s definately a great deal to find out about this topic.
I like all of the points you’ve made.
I have read so many articles or reviews on the topic of the blogger lovers except this article is really a nice article,
keep it up.
Very informative post.Really looking forward to read more. Cool.
It’s going to be ending of mine day, except before ending I am reading this impressive article to increase my knowledge.
Great, thanks for sharing this post.Really looking forward to read more. Awesome.
Major thanks for the article.Really looking forward to read more. Really Cool.
Major thanks for the article post.Really looking forward to read more. Great.
Appreciate you sharing, great blog post.Really thank you! Awesome.
I truly appreciate this blog article.Thanks Again. Awesome.
This is really interesting, You’re a very skilled blogger.
I’ve joined your rss feed and look forward to seeking more of your magnificent post.
Also, I’ve shared your web site in my social networks!
Great blog post.Really looking forward to read more. Will read on…
Thanks a lot for the post.Much thanks again. Really Cool.
Thanks a lot for the blog post. Much obliged.
It’s not my first time to pay a visit this
web page, i am visiting this site dailly and take fastidious facts from here all the time.
wow, awesome blog post.Really looking forward to read more. Really Cool.
I have been exploring for a little bit for any high quality articles or blog posts on this
sort of space . Exploring in Yahoo I ultimately stumbled upon this site.
Studying this info So i’m glad to exhibit that I’ve an incredibly good uncanny feeling I came upon just what I needed.
I so much indubitably will make sure to don?t forget this site and provides it a glance on a relentless basis.
Very good blog post.Really looking forward to read more. Keep writing.
I really enjoy the blog post.Really looking forward to read more. Great.
Great article.Thanks Again. Much obliged.
Awesome blog post.Much thanks again. Really Cool.
Thank you for your blog article.Much thanks again. Really Cool.
Major thanks for the post.Thanks Again. Fantastic.
Someone necessarily help to make significantly articles I might state.
This is the very first time I frequented your web page and thus far?
I amazed with the research you made to create this particular put up extraordinary.
Fantastic job!
Thanks for the blog article. Will read on…
I think this is a real great blog article.Thanks Again. Awesome.
I am so grateful for your blog article.Really looking forward to read more. Fantastic.
Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something.
I think that you could do with some pics
to drive the message home a bit, but instead of that, this is magnificent blog.
A great read. I’ll definitely be back.
whoah this blog is magnificent i really like reading your
posts. Stay up the good work! You recognize, lots of people are searching
around for this information, you could aid them greatly.
Fantastic post. Really Cool.
This is one awesome article.Really thank you! Much obliged.
Really when someone doesn’t understand then its up to other users that
they will assist, so here it happens.
Hi friends, how is the whole thing, and what you would like to say regarding this piece of writing, in my view its in fact awesome for me.
Really informative post.Really looking forward to read more. Awesome.
I appreciate you sharing this article post.Thanks Again.
A round of applause for your article post.Really thank you! Really Cool.
I needed to thank you for this great read!! I absolutely enjoyed every little bit
of it. I have you saved as a favorite to check out new things you post…
Fantastic blog.Really thank you! Fantastic.
Thanks for the blog.Really looking forward to read more. Much obliged.
Im obliged for the blog.Much thanks again. Really Great.
First off I want to say wonderful blog! I had a quick question that I’d like to ask if you
don’t mind. I was curious to know how you center yourself
and clear your thoughts prior to writing. I’ve had a difficult time clearing
my thoughts in getting my ideas out. I do take pleasure in writing
but it just seems like the first 10 to 15 minutes are wasted simply
just trying to figure out how to begin. Any suggestions or tips?
Many thanks!
I really liked your post.Thanks Again. Really Cool.
Great, thanks for sharing this article.Much thanks again. Great.
This is one awesome article.Much thanks again.
Thank you ever so for you article post.Thanks Again. Really Cool.
It’s very straightforward to find out any matter on web as compared to books, as I found this article at this website.
That is really interesting, You’re an excessively skilled blogger.
I have joined your rss feed and sit up for in the hunt
for more of your wonderful post. Also, I’ve shared your website in my social
networks
Thanks for every other informative blog. The place else may just I get that kind of info written in such a perfect approach? I’ve a project that I’m just now running on, and I’ve been on the glance out for such information.
I value the blog. Cool.
I appreciate you sharing this blog. Really Great.
A big thank you for your blog post.Really thank you!
Fantastic post.Much thanks again. Will read on…
A big thank you for your article post.Really looking forward to read more. Will read on…
I appreciate you sharing this article post.Really looking forward to read more. Cool.
Im grateful for the article.Thanks Again. Fantastic.
Major thankies for the blog article.Much thanks again. Keep writing.
Very informative post.Thanks Again. Really Cool.
Major thanks for the blog post. Really Cool.
I really like and appreciate your post.Thanks Again. Great.
I really enjoy the post.Really thank you! Will read on…
Thanks again for the article post.Much thanks again. Really Cool.
Really appreciate you sharing this article post.Really looking forward to read more. Fantastic.
Looking forward to reading more. Great blog post.Much thanks again. Fantastic.
I really like and appreciate your blog. Cool.
Muchos Gracias for your blog article. Want more.
I really enjoy the blog article.Really thank you! Keep writing.
Im thankful for the post. Really Great.
Thank you ever so for you blog post.Thanks Again.
I truly appreciate this article post.Much thanks again.
Very informative blog.Really looking forward to read more. Great.
Thanks again for the post.Much thanks again. Cool.
Thank you for sharing your thoughts. I truly appreciate your efforts and I am
waiting for your next post thank you once again.
I really liked your article post.Much thanks again. Cool.
Wow, great blog article.Really looking forward to read more. Awesome.
I appreciate you sharing this blog article. Fantastic.
I really enjoy the article post.Really thank you! Much obliged.
I enjoy what you guys are up too. This type of clever work and reporting!
Keep up the wonderful works guys I’ve added you guys to our blogroll.
bookmarked!!, I like your web site!
I am so grateful for your article post. Really Cool.
I am so grateful for your post.Really thank you! Really Great.
I really liked your blog post.Really thank you! Awesome.
Wow, great article. Want more.
Im grateful for the blog. Fantastic.
Awesome blog post.
If some one desires expert view concerning running
a blog afterward i recommend him/her to pay a quick
visit this blog, Keep up the pleasant job.
Very good blog post.Much thanks again. Keep writing.
Im thankful for the blog article. Fantastic.
Great post! We will be linking to this particularly great
article on our website. Keep up the good writing.
I am so grateful for your post.Really looking forward to read more. Really Great.
Major thanks for the blog post.Much thanks again. Cool.
Thanks so much for the post.Really looking forward to read more.
Appreciate you sharing, great article.Thanks Again.
Appreciate you sharing, great blog post.Really looking forward to read more. Really Cool.
Looking forward to reading more. Great blog.Much thanks again. Fantastic.
I loved your blog post.Much thanks again. Really Great.
Appreciate you sharing, great post. Great.
Very informative article.Really thank you! Fantastic.
I loved your blog post.Really looking forward to read more. Cool.
I really liked your blog.Really thank you! Fantastic.
Really appreciate you sharing this article.Thanks Again. Much obliged.
Im obliged for the blog post.Really thank you! Great.
Great article post.Much thanks again. Great.
wow, awesome post.Much thanks again. Keep writing.
Hi there friends, its enormous article on the topic of
cultureand completely defined, keep it up all the time.
Say, you got a nice article post. Cool.
A round of applause for your blog post.Really looking forward to read more. Really Great.
Enjoyed every bit of your blog article.Thanks Again. Really Great.
I value the blog article. Great.
Really appreciate you sharing this post. Really Great.
I truly appreciate this article. Cool.
Im thankful for the blog article.Much thanks again. Will read on…
Appreciate you sharing, great blog post. Cool.
I am so grateful for your article. Fantastic.
Thanks-a-mundo for the blog. Really Great.
Thanks for the blog article. Really Great.
Great, thanks for sharing this post.Thanks Again. Will read on…
Very good article. Keep writing.
Hurrah! Finally I got a weblog from where I be capable
of in fact take valuable facts concerning my study and knowledge.
This is one awesome blog post.Really thank you! Cool.
A big thank you for your post.Thanks Again. Really Cool.
Thanks for the blog post.Really looking forward to read more. Great.
Im grateful for the article post.Really thank you! Keep writing.
I value the blog.Really looking forward to read more. Really Great.
Major thanks for the post.Really looking forward to read more. Really Cool.
Im obliged for the article. Really Great.
Awesome blog article.Really thank you! Want more.
My partner and I absolutely love your blog and
find nearly all of your post’s to be what precisely I’m looking for.
Would you offer guest writers to write content available for you?
I wouldn’t mind producing a post or elaborating on a lot of
the subjects you write about here. Again, awesome weblog!
Im thankful for the article.Really looking forward to read more. Fantastic.
I cannot thank you enough for the article post.Much thanks again. Fantastic.
Very informative article.Much thanks again. Really Cool.
Hey, thanks for the blog article.Really thank you! Great.
Enjoyed every bit of your post.Thanks Again. Cool.
Hey there would you mind letting me know which webhost you’re working with?
I’ve loaded your blog in 3 completely different internet browsers and I must
say this blog loads a lot quicker then most. Can you recommend a good web hosting provider at a reasonable price?
Kudos, I appreciate it!
Im obliged for the post.Really looking forward to read more. Keep writing.
Thanks for the blog article.Thanks Again. Awesome.
Thanks a lot for the article post.Much thanks again. Cool.
Thanks for sharing, this is a fantastic article post.Really looking forward to read more. Cool.
I value the blog. Fantastic.
A round of applause for your article.Really thank you! Cool.
I think this is a real great blog.Really thank you! Awesome.
I cannot thank you enough for the post.Thanks Again. Want more.
Great post.Thanks Again. Awesome.
Very informative article.Thanks Again. Want more.
I appreciate you sharing this blog.Much thanks again. Really Great.
Really informative blog.Thanks Again.
Say, you got a nice blog article.Much thanks again. Really Cool.
Thanks again for the article.Really thank you! Will read on…
This is a wonderful website. The site owner has carried out a superb job of putting it together, the info here is really insightful.
An impressive share! I’ve just forwarded this onto a friend who had been conducting a little
homework on this. And he in fact bought me dinner because I found it for him…
lol. So let me reword this…. Thank YOU for the meal!! But yeah, thanx for spending time to discuss this subject
here on your internet site.
I really enjoy the blog.Thanks Again. Will read on…
I really enjoy the article. Great.
A round of applause for your post. Really Cool.
Really enjoyed this article post.Much thanks again. Really Cool.
I really liked your blog post.Thanks Again. Awesome.
I am so grateful for your post.Much thanks again. Really Great.
Im grateful for the blog article. Want more.
Really enjoyed this blog.Really thank you! Really Great.
Im obliged for the article post.Thanks Again.
This is the right site for anybody who really wants to
find out about this topic. You understand so much
its almost tough to argue with you (not that I actually will need to…HaHa).
You definitely put a fresh spin on a subject which has been discussed for ages.
Great stuff, just excellent!
When I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks!
Major thankies for the article. Cool.
Very informative article post.Thanks Again. Want more.
I value the blog article.Thanks Again. Awesome.
Enjoyed every bit of your blog article.Really looking forward to read more. Keep writing.
Thank you for your post.Really thank you! Will read on…
Awesome post. Awesome.
I really enjoy the blog article. Really Great.
Wow, great post.Much thanks again. Want more.
Looking forward to reading more. Great blog post.Really looking forward to read more. Much obliged.
I really like and appreciate your blog.Really thank you!
Very neat blog.Really looking forward to read more. Keep writing.
I value the post. Really Great.
Im thankful for the blog.Really looking forward to read more. Want more.
A big thank you for your post.Really thank you! Really Cool.
I really enjoy the blog post.Much thanks again. Much obliged.
Awesome blog post. Will read on…
Awesome article.Much thanks again. Will read on…
You’ve made some decent points there. I looked on the web for more info about the issue and found most people will go along with your views on this website.|
Great article post.Really looking forward to read more. Cool.
Heya i am for the first time here. I came across this board and I find It really useful & it helped me out a lot. I hope to give something back and help others like you aided me.|
I think this is a real great blog article.Really thank you! Really Great.
I am curious to find out what blog platform you have been using? I’m experiencing some minor security problems with my latest website and I’d like to find something more safe. Do you have any recommendations?|
When someone writes an post he/she keeps the thought of a user in his/her mind that how a user can understand it. Therefore that’s why this post is great. Thanks!|
Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your next post thank you once again.|
Wow, great blog article.Much thanks again. Will read on…
Im grateful for the article.Really looking forward to read more. Will read on…
Im grateful for the article post.Really looking forward to read more. Awesome.
Very good article post.Really looking forward to read more. Cool.
Hi! I just wanted to ask if you ever have any issues with hackers? My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due to no back up. Do you have any methods to stop hackers?|
Enjoyed every bit of your article post.Really thank you! Really Cool.
Awesome article.Much thanks again. Want more.
Very good blog.Much thanks again. Fantastic.
I really like and appreciate your blog post.Really looking forward to read more. Cool.
Hello! I know this is kinda off topic but I was wondering if you knew where I could locate a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having trouble finding one? Thanks a lot!|
I appreciate you sharing this blog post.Really looking forward to read more. Fantastic.
Thank you for your article post.Really looking forward to read more. Fantastic.
Very good post.Thanks Again.
I appreciate you sharing this blog article.Really looking forward to read more. Much obliged.
Thanks , I have recently been searching for information about this subject for ages and yours is the greatest I’ve found out so far. However, what about the bottom line? Are you sure about the source?|
I’ve been browsing online more than 2 hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my view, if all site owners and bloggers made good content as you did, the internet will be much more useful than ever before.|
Thanks again for the article. Really Great.
Very informative blog article.Really thank you! Will read on…
Really appreciate you sharing this blog.Really looking forward to read more. Awesome.
I constantly emailed this website post page to all my friends, because if like to read it afterward my links will too.|
When I initially left a comment I appear to have clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I receive 4 emails with the exact same comment. Is there an easy method you are able to remove me from that service? Cheers!|
Very quickly this website will be famous amid all blog people, due to it’s fastidious articles|
Im grateful for the article.Much thanks again. Really Cool.
Great, thanks for sharing this blog post.Really thank you! Great.
Truly no matter if someone doesn’t know then its up to other people that they will help, so here it happens.|
I really like and appreciate your blog post.Really thank you! Great.
Looking forward to reading more. Great blog article.Much thanks again. Want more.
Very good article.Thanks Again. Awesome.
I value the post.Really thank you!
Hi there! I just wish to give you a big thumbs up for your great information you have here on this post. I am coming back to your web site for more soon.|
Hey, thanks for the blog post.Really looking forward to read more. Much obliged.
Thanks for the blog article.Really looking forward to read more. Want more.
Pretty! This has been a really wonderful article. Thanks for supplying these details.|
I think the admin of this website is really working hard in favor of his website, as here every data is quality based material.|
Im thankful for the blog post.Thanks Again. Really Great.
I value the article.Thanks Again. Want more.
What’s up, always i used to check website posts here in the early hours in the daylight, for the reason that i like to learn more and more.|
Very nice article, exactly what I was looking for.|
Hi there! This is kind of off topic but I need some help from an established blog. Is it very difficult to set up your own blog? I’m not very techincal but I can figure things out pretty fast. I’m thinking about creating my own but I’m not sure where to start. Do you have any ideas or suggestions? Thank you|